Flutter PDF Rotation - flutter

I use this package (https://pub.dev/packages/pdf) to create PDF files with app.. Now I can't find a way to rotate the page of PDF.

Try this. Comments in code.
pdf.addPage(
pw.Page(
pageTheme: pw.PageTheme(
// orientation: pw.PageOrientation.landscape, //this set the orientation of the content of the page, not the page itself. Which confuses most people
pageFormat: PdfPageFormat.a4.landscape, //this is what you want
...
),
build: (ctx) => ChildWidget(),
...
Source: https://github.com/DavBfr/dart_pdf/issues/557

Related

CREATE INVOICE PDF using FLUTTER WEB

I need to create a path to temporarily store my pdf file before sharing it. but path_provider does not support web. please what other way can i use to share the pdf decuments.
knowing that I want to create an incoice.
here is the context with some code
Future getPdf(Uint8List screenShot) async {
pw.Document pdf = pw.Document();
final img = pw.MemoryImage(screenShot);
pdf.addPage(
pw.Page(
pageFormat: PdfPageFormat.a4,
build: (context) {
return pw.Expanded(
child: pw.Image(img),
);
},
),
);
// File pdfFile = File('Your path + File name');
// pdfFile.writeAsBytesSync(await pdf.save());
print(pdf);
}
in this specific case I would like to use an alternative to path_provider

How to add back button to WebView in Flutter to dismiss the WebView altogether?

Currently when I tap on an image, it should open a web view as the image object has an associated url. I am using the url_launcher library for Flutter, and I have implemented the code as follows:
onTap: () async {
final url = image.url;
if (await canLaunch(url)) {
await launch(
url,
forceSafariVC: true,
forceWebView: true,
enableJavaScript: true,
);
}
},
My understanding is that this launches a WebView, which is an in-app browser rather than taking the user out of the app and into a separate browser app. This works fine, but the page loads much slower and Javascript elements do not work properly (e.g. animated text on websites). On the other hand,
onTap: () async {
final url = banners[index].url;
if (await canLaunch(url)) {
await launch(
url
);
}
},
works much better as it is faster and everything loads in properly, but it opens an external browser, which is not what I want.
Another issue is that I would like to add a Done button on the top left corner of the WebView to completely exit the WebView and return to where I was in the app. I only have a back button on the bottom left (on the Android emulator), that lets me go to the previous page I was at in the browser.
How do I customise the layout of the WebView, if I do not have any access to it? The url_launcher seems to handle the WebView creation internally, so I'm wondering how can I gain access from the above code to add that button?
Thank you!
If you use the native webview in this manner then you can't customise the ui. But instead, since you are displaying image you can use image.network from flutter.
Image.network(imgURL,fit: BoxFit.fill,
loadingBuilder:(BuildContext context, Widget child,ImageChunkEvent loadingProgress) {
if (loadingProgress == null)
return child;
return Center(
child: CircularProgressIndicator(
value: loadingProgress.expectedTotalBytes != null ?
loadingProgress.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes
: null,
),
);
},
),
Or, you can also use official webview plugin from flutter team to create in app web view.
webview_flutter: ^2.3.1
In this approaches if you add a back button in ui you can the use Navigator.pop(context); on onPressed property in button to go back

Flutter syncfusion_flutter_pdf package

I would like to show an image from firebase with syncfusion_flutter_pdf but I couldn't do it. I used exact same code block from official documentation but it didn't help me too.
The documentation gives the code below but there are no spesific way for Network image or something
Can anyone have an idea
Easiest way to use flutter printing package flutter printing
const imageProvider = const NetworkImage('https/image.png');
final image = await flutterImageProvider(imageProvider);
doc.addPage(pw.Page(
build: (pw.Context context) {
return pw.Center(
child: pw.Image(image),
); // Center
})); // Page

Remove url bar from chromeSafariBrowser in flutter_inappwebview

I am using ChromeSafariBrowser class of flutter_inappwebview to show the webview which contains videos. I am using this class cause it supports pip and also shows media controls on video play which most of dependencies doesnt provide. Now I want to remove the url bar from the top, how can i achieve it?
Any help is appreciated, thanks in advance..
I want to remove the rectangular marked area in this picture
Following is my sample code
RaisedButton(
onPressed: () async {
await widget.browser.open(
url: "https://player.vimeo.com/api/demo",
options: ChromeSafariBrowserClassOptions(
android: AndroidChromeCustomTabsOptions(
addDefaultShareMenuItem: false,
enableUrlBarHiding:true,
toolbarBackgroundColor: "#000000"
),
ios: IOSSafariOptions(
barCollapsingEnabled: true,
preferredBarTintColor: "#000000"
)
),
);
},
child: Text("Open Chrome Safari Browser")
)

Flutter onTap get particular Image source from htmlWidget

I have html coming from Json and saved it in the String and thereafter used flutter_widget_from_html dependency to view html as webview.
I want to get particular Image url onTap particular image in htmlWidget.
In android i have onTouchListener from where we can easily extract the image but I don't know how to do it in Flutter.
Directionality(textDirection: TextDirection.rtl,
child: HtmlWidget("<p><img class="alignnone size-full wp-image-231636" src="http://abc/wp-content/uploads/2019/09/big13-48.jpg" alt="" width="600" height="800" srcset="http://abc/wp-content/uploads/2019/09/big13-48.jpg 600w, http://abc/wp-content/uploads/2019/09/big13-48-450x600.jpg 450w" sizes="(max-width: 600px) 100vw, 600px" /></p>",
webView: true,
),
),
You can do that by using builderCallback. It provide you the functionality to customize the UI widgets while its rendering.
Follow this url.
https://github.com/daohoangson/flutter_widget_from_html/issues/50#issuecomment-500928520
dependencies:
flutter_html: ^0.11.0
You will receive that image inside it.
onImageTap: (src) {
// Display the image in large form.
}
Reference link:
https://github.com/Sub6Resources/flutter_html