Ejemplo n.º 1
0
def as_pdf(request, document_id):
    form = LargePrintProfileForm(request.POST)

    if not form.is_valid():
        return HttpResponseRedirect(reverse('browse_detail', args=[document_id]))

    document = Document.objects.get(pk=document_id)

    inputFile = document.latest_version().content.path
    outputFile = "/tmp/%s.pdf" % document_id
    DaisyPipeline.dtbook2pdf(inputFile, outputFile, **form.cleaned_data)

    return render_to_mimetype_response('application/pdf', document.title.encode('utf-8'), outputFile)
Ejemplo n.º 2
0
def preview_pdf(request, document_id):
    document = get_object_or_404(Document, pk=document_id)

    if request.method == 'POST':
        form = LargePrintProfileForm(request.POST)
        if form.is_valid():
            inputFile = document.latest_version().content.path
            outputFile = "/tmp/%s.pdf" % document_id
            DaisyPipeline.dtbook2pdf(inputFile, outputFile, **form.cleaned_data)
            return render_to_mimetype_response('application/pdf', 
                                               document.title.encode('utf-8'), outputFile)
    else:
        form = LargePrintProfileForm()

    return render_to_response('documents/todo_pdf.html', locals(),
                              context_instance=RequestContext(request))
Ejemplo n.º 3
0
def preview_pdf(request, document_id):
    document = get_object_or_404(Document, pk=document_id)

    if request.method == 'POST':
        form = LargePrintProfileForm(request.POST)
        if form.is_valid():
            inputFile = document.latest_version().content.path
            outputFile = "/tmp/%s.pdf" % document_id
            StandardLargePrint.dtbook2pdf(inputFile, outputFile,
                                          images=document.image_set.all(), **form.cleaned_data)
            filename = document.title + u" " + form.cleaned_data['font_size']
            return render_to_mimetype_response('application/pdf', 
                                               filename.encode('utf-8'), outputFile)
    else:
        form = LargePrintProfileForm()

    return render(request, 'documents/todo_pdf.html', locals())