- Code: Select all
//====================================================================================================
// use Spire.PDF to dump to user
PdfDocument pdfdoc = new PdfDocument();
PdfHtmlLayoutFormat htmlLayoutFormat = new PdfHtmlLayoutFormat();
//htmlLayoutFormat.FitToPage = Clip.Width; // doesn't work
htmlLayoutFormat.TrimPage = Clip.Width; // doesn't work
htmlLayoutFormat.FitToHtml = Clip.Width; // doesn't work
htmlLayoutFormat.IsWaiting = false;
PdfPageSettings settings = new PdfPageSettings();
settings.Size = PdfPageSize.Letter;
string htmlCode = Session.Contents["reportcontents"].ToString();
Thread thread = new Thread(() => { pdfdoc.LoadFromHTML(htmlCode, false, settings, htmlLayoutFormat); });
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
MemoryStream msDoc = new MemoryStream();
pdfdoc.SaveToStream(msDoc, FileFormat.PDF);
pdfdoc.SaveToHttpResponse("report.pdf", this.Response, HttpReadType.Save);
// end output to PDF for the user
//====================================================================================================
C# in ASP.Net, developer licensed.
this does create the report and allows me to capture it with the save dialogue.
When I open the PDF, it is improperly scaled, no matter what I do, I can't get it to scale correctly.
The div it is in is set to a static width of 1400px, the table within the div is set to a static width of 1400px, the final image output is more like 700px, if that, more like 640px.
so it clips over 50% of the actual resulting information off and I am stuck with half of what I need.
Any suggestions?