Developer forum

Forum » Development » Naming PDF

Reply
Is it possible to name the pdf generated from the DW PDF generator?



Right now the pdf has the standard name MyPDF.pdf when it is opened, is it possible to give a custom name to the file?



- Sune

Replies

 
Nicolai Høeg Pedersen
Reply
sune@fonqi.dk wrote:



Is it possible to name the pdf generated from the DW PDF generator?





Right now the pdf has the standard name MyPDF.pdf when it is opened, is it possible to give a custom name to the file?

- Sune

Hi Sune


Do like this instead of using the built in download function.


Dim objPDFData() As Byte


objPDFData = objPDF.GetData()


HttpContext.Current.Response.Clear()


HttpContext.Current.Response.AddHeader("Content-Type", "application/force-download")


HttpContext.Current.Response.AddHeader("Content-Type", "application/octet-stream")


HttpContext.Current.Response.AddHeader("Content-Type", "application/pdf")


HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=""MyPDF.PDF""")


HttpContext.Current.Response.BinaryWrite(objPDFData)

 
Reply
Thanx for the reply, just a couple of questions in response to that.



the objPdfdata you use in your example, is that the pdf object?



It doesnt seem to have a GetData() method?



my Code looks like this:



 Dynamicweb.PDFClass pdf = new PDFClass("http://www.****.dynamicweb.dk/GetContract.aspx?id=" + id);               



Response.Clear();           

Response.AddHeader("Content-Type", "application/force-download");

Response.AddHeader("Content-Type", "application/octet-stream");

Response.AddHeader("Content-Type", "application/pdf");

Response.AddHeader("Content-Disposition", "attachment; filename='Contract.pdf'");

Response.BinaryWrite(pdf);



how do I BinaryWrite my pdf object?



Is it possible to set the size of the pdf? (fx to A4)



kind regards



Sune
 
Nicolai Høeg Pedersen
Reply

Hi Sune


 


I was a little too fast with my example. objPDf is the internal pdf object and is not available public.


 


So if you need to control then name you have 3 options:


1) Wait for the next service release next week. I've added an overload of HttpStream() where you can specify the filename.


 


2) Call SaveToFile() and save the pdf to disk and then redirect to it or sent using the first mentioned method


 


3) Code directly to the abc pdf object - then you can control all things - like papersize.

 
Reply
thanx



HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=""anotherName.PDF""")

The above actually works so thats cool.

 


about the size of the pdf, is it possible to define the size of the document?


- Sune

 
Nicolai Høeg Pedersen
Reply

No - not with this implementation.


 


Then you would have to do your own coding against the pdf object.


 


Otherwise try to force your html to some size that matches the A4.

 
Reply
I tried using a A4 format jpeg as background image on this page.



but it seems the aspect ratio of the pdf is locked. Is there any way to circumvent this so we can get a A4 format?



http://rentamini.net.dynamicweb.dk/GetInvoice.aspx?invoice=7C457E696B3855B4D9175956BA71EBEF

http://rentamini.net.dynamicweb.dk/GetInvoicePDF.aspx?invoice=7C457E696B3855B4D9175956BA71EBEF



kind regards



Sune fengel
 
Nicolai Høeg Pedersen
Reply

No - not with this implementation.


 


Then you would have to do your own coding against the pdf object.

 

You must be logged in to post in the forum