We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Detect Cutoff

Hi,

Is there a way to detect if parts of the document would be cutoff?

Here is my sample code and I’ve included a doc that would be cutoff.

var doc = new Document(inputPath);   
var pdfSaveOptions = new PdfSaveOptions()
                {
                    SaveFormat = SaveFormat.Pdf
                }; 
doc.Save(outputPath, pdfSaveOptions);

CutoffTable2016.zip (10.6 KB)

@ccuster68,

Please ZIP and upload your input Word document and Aspose.Words generated PDF file showing the undesired behavior here for testing. We will then investigate the issue on our end and provide you more information.

Hi Awais,

Thank you for getting back. Here is the zip, I included where a table is cut off as well as a chart. Correcting this is great. Detecting if there is cutoff is good as well.

Thanks,
Charles
CutOff.zip (85.1 KB)

@ccuster68,

But, the problems are already present in input Word documents (CutoffChart2016.docx and CutoffTable2016.docx). How did you generate these Word documents? If you convert (Save As) these Word documents to PDF format by using MS Word, then you will see the same outputs as produced by Aspose.Words.

This can happen in different ways. We wanted to be able to detect it. For example say you have a document that has an orientation of landscape, and the user is changing the documents to portrait. This could cause cut off. Code is below, In the zip the document there are 2 files:

  1. CutoffTable2016Land.docx - The file that shows all in landscape orientation

  2. produced.pdf - the produced file that shows cut off.

    var doc = new Aspose.Words.Document(@“F:\Share\TestData\Word\cutoff\CutoffTable2016Land.docx”);
    foreach (Section section in doc.GetChildNodes(NodeType.Section, true))
    {
    section.PageSetup.Orientation = Aspose.Words.Orientation.Portrait;
    }

    doc.UpdatePageLayout();
    doc.Save(@“c:\temp\produced.pdf”);Cutoff2.zip (45.3 KB)

@ccuster68,

But, if you please do the same steps by using MS Word 2019, then you will notice that Aspose.Words’ output is similar to what MS Word produces. However, in this case, you can get the expected output by using the following code:

Document doc = new Document("E:\\Cutoff2\\CutoffTable2016Land.docx");

foreach (Section section in doc.GetChildNodes(NodeType.Section, true))
{
    section.PageSetup.Orientation = Aspose.Words.Orientation.Portrait;
}

foreach (Table tab in doc.GetChildNodes(NodeType.Table, true))
{
    tab.AutoFit(AutoFitBehavior.AutoFitToWindow);
}

//doc.UpdateTableLayout();
doc.UpdatePageLayout();

doc.Save("E:\\Cutoff2\\19.3.pdf");

Awais,
Thanks for the info