Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 在颤振中使用syncfusion软件包的PDF内部导航_Flutter_Pdf_Linker_Syncfusion - Fatal编程技术网

Flutter 在颤振中使用syncfusion软件包的PDF内部导航

Flutter 在颤振中使用syncfusion软件包的PDF内部导航,flutter,pdf,linker,syncfusion,Flutter,Pdf,Linker,Syncfusion,我一直在使用flifter中的一个应用程序生成一个包含索引列表及其相应内容部分的PDF文件。我想要实现的是在单击索引元素时导航到特定内容。我遵循了这里的文档:,但它没有解决我的问题 import 'dart:ui'; import 'package:flutter/services.dart'; import 'package:path_provider/path_provider.dart'; import 'dart:io'; import 'package:share/share.

我一直在使用flifter中的一个应用程序生成一个包含索引列表及其相应内容部分的PDF文件。我想要实现的是在单击索引元素时导航到特定内容。我遵循了这里的文档:,但它没有解决我的问题

import 'dart:ui';

import 'package:flutter/services.dart';
import 'package:path_provider/path_provider.dart';   
import 'dart:io';
import 'package:share/share.dart';
import 'package:lorem_ipsum/lorem_ipsum.dart';
import 'package:syncfusion_flutter_pdf/pdf.dart';

reportView(context) async {
  PdfDocument document = PdfDocument();
  PdfPage firstPage = document.pages.add();
  PdfPage secondPage = document.pages.add();
     

  Rect firstRectangle = Rect.fromLTWH(0, 0, 150, 100);
  Rect secondRectangle = Rect.fromLTWH(170, 100, 0, 0);

  //Contents for first page
  firstPage.graphics.drawString(
      'Hello World!!!', PdfStandardFont(PdfFontFamily.helvetica, 27),
      brush: PdfBrushes.darkBlue, bounds: firstRectangle);

  //Contents for second page
  secondPage.graphics.drawString(
      loremIpsum(words: 60, paragraphs: 3, initWithLorem: true), PdfStandardFont(PdfFontFamily.helvetica, 27),
      brush: PdfBrushes.darkBlue,bounds: secondRectangle);


  //Creating the first annotation
  PdfDocumentLinkAnnotation firstAnnotation = new PdfDocumentLinkAnnotation(firstRectangle,PdfDestination(secondPage));
  firstPage.annotations.add(firstAnnotation);

  //Creating the second annotation
  PdfDocumentLinkAnnotation secondAnnotation = new PdfDocumentLinkAnnotation(secondRectangle,PdfDestination(firstPage));
  firstPage.annotations.add(secondAnnotation);

  //Saving the document
  final String dir = (await getApplicationDocumentsDirectory()).path;
  final String path = '$dir/App_' + '.pdf';
  await File(path).writeAsBytes(document.save());
  print(path);
  Share.shareFiles([path]);
  document.dispose();
}

在最终生成的PDF中,我似乎找不到任何可点击的点。我做错了什么?对于内部导航的正常工作,我还需要做些什么吗?

目前我们不支持文档链接注释的绘图外观。因此,我们建议您使用页面图形绘制可点击点,如下所示

//Create PDF document
PdfDocument document = PdfDocument();
//Add pages
PdfPage firstPage = document.pages.add();
PdfPage secondPage = document.pages.add();

Rect firstRectangle = Rect.fromLTWH(0, 0, 150, 100);
Rect secondRectangle = Rect.fromLTWH(170, 100, 150, 100);

//Contents for first page
firstPage.graphics.drawString(
    'Hello World!!!', PdfStandardFont(PdfFontFamily.helvetica, 27),
    brush: PdfBrushes.darkBlue, bounds: firstRectangle);

//Contents for second page
secondPage.graphics.drawString(
    'second page text', PdfStandardFont(PdfFontFamily.helvetica, 27),
    brush: PdfBrushes.darkBlue, bounds: secondRectangle);

//Creating the first annotation
PdfDocumentLinkAnnotation firstAnnotation = new PdfDocumentLinkAnnotation(
    firstRectangle, PdfDestination(secondPage));
firstPage.annotations.add(firstAnnotation);

//Draw appearance.
firstPage.graphics
    .drawRectangle(bounds: firstRectangle, pen: PdfPens.black);

//Creating the second annotation
PdfDocumentLinkAnnotation secondAnnotation = new PdfDocumentLinkAnnotation(
    secondRectangle, PdfDestination(firstPage));
firstPage.annotations.add(secondAnnotation);

//Draw appearance.
firstPage.graphics
    .drawRectangle(bounds: secondRectangle, pen: PdfPens.black);

//Saving the document
final String dir = (await getApplicationDocumentsDirectory()).path;
final String path = '$dir/App_' + '.pdf';
await File(path).writeAsBytes(document.save());
print(path);
Share.shareFiles([path]);
document.dispose();
第二个文档链接批注也添加了宽度和高度为0,0,原因是批注配置不正确。我们也更改了上述代码的边界

你能在你方尝试上述变更,并让我们知道是否满足你方要求

问候,, 阿南德潘查穆尔蒂